﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 类的方法成员
{
    public class car
    {
        public double OilMeter;           //油表数值，单位：升
        public double OilVolme;           //油箱容量，单位：升
        public double OilCosumption;      //油耗，每百公里消耗汽油数量，单位：升
        public double Mileage;            //里程数，单位：公里
        public car()
        {
            OilMeter = 0;
            OilVolme = 50;
            OilCosumption = 9;
            Mileage = 0;
            
        }
        public void Info()   
        {
            Console.WriteLine("这辆车已经行驶{0}公里，油箱中还有{1}升汽油，油耗为百公里{2}升",Mileage, OilMeter, OilCosumption);
        }
        public void Fule(int x)     //加油
        {
            if (OilMeter + x < OilVolme)
            { 
                Console.WriteLine("向油箱加入{0}升汽油，油箱中现有{1}升汽油", x, OilMeter + x);
                OilMeter = OilMeter + x;
            }
            else
            {

                Console.WriteLine("油箱加满，加入{0}升汽油", OilVolme - OilMeter);
                OilMeter = OilVolme;
            }

        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            car car1 = new car();
            car1.Info();
            car1.Fule(10);
            car1.Fule(70);
            car1.Info();

        }
    }
}
